﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Script.Serialization;


namespace M.Dao.Client.Core
{
    public class DataResult<T>
    {
        private bool _result = false;

        public bool result
        {
            get { return _result; }
            set { _result = value; }
        }

        private string _message = string.Empty;

        public string message
        {
            get { return _message; }
            set { _message = value; }
        }

        private T _data;

        public T data
        {
            get { return _data; }
            set { _data = value; }
        }

        public override string ToString()
        {
            JavaScriptSerializer jss = new JavaScriptSerializer();

            return jss.Serialize(this);
        }
        public static DataResult<T> ParseJson(string json)
        {
            JavaScriptSerializer jss = new JavaScriptSerializer();

            return jss.Deserialize<DataResult<T>>(json);
        }
    }
}